package com.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.EasyUITreeNavResult;
import com.taotao.service.MainNavService;
import com.taotao.service.TreeNavService;
import com.taotao.utils.JsonUtils;

@Controller
public class BackupPageController {

	@Autowired
	private TreeNavService treeNavService;

	@Autowired
	private MainNavService mainNavService;

	@RequestMapping("/")
	public String showIndex() {
		return "index";
	}

	@RequestMapping("/page/{page}")
	public String showPage(@PathVariable String page) {
		return page;
	}

	/**
	 * 获取树导航节点
	 * 
	 * @param treenavid
	 * @return
	 */
	@RequestMapping("/nav/treenav/{mainnavid}/{treenavid}")
	@ResponseBody
	public String getTreeNav(@PathVariable("mainnavid") Long mainnavid, @PathVariable("treenavid") Long treenavid) {
		List<EasyUITreeNavResult> treeNav = treeNavService.getTreeNav(treenavid, mainnavid);
		return JsonUtils.objectToJson(treeNav);
	}

	/**
	 * 获取主菜单导航
	 * 
	 * @param treenavid
	 * @return
	 */
	@RequestMapping("/nav/mainnav/{mainnavid}")
	@ResponseBody
	public String getMainNav(@PathVariable("mainnavid") Long mainnavid) {
		List<EasyUITreeNavResult> mainNav = mainNavService.getMainNav(mainnavid);
		return JsonUtils.objectToJson(mainNav);
	}
}
